import { defineStore } from 'pinia'

export const usePermissionStore = defineStore('permission', {
  state: () => ({
    routes: []
  }),

  actions: {
    // 根据角色生成路由
    async generateRoutes(role) {
      // 这里可以根据角色返回不同的路由配置
      const routes = []
      
      // 管理员可以访问所有路由
      if (role === 'SUPER_ADMIN') {
        routes.push(
          {
            path: '/settings',
            component: () => import('@/layouts/MainLayout.vue'),
            children: [
              {
                path: 'profile',
                name: 'Profile',
                component: () => import('@/views/settings/Profile.vue'),
                meta: { title: '个人设置', requiresAuth: true }
              }
            ]
          }
        )
      }
      
      this.routes = routes
      return routes
    }
  }
}) 